package cn.edu.zjut.mina.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import org.springframework.web.bind.annotation.RestController;

import cn.edu.zjut.mina.service.IDownloadService;
import cn.edu.zjut.mina.service.ILoginService;


@Controller
@RestController
@RequestMapping("/download")
public class ApkDownloadAction {
	
	@Qualifier("downloadService")
	@Autowired
	private IDownloadService downloadService;
	
	
	/**
	 * apk文件下载
	 * @param cateogry 文件名
	 * @param request
	 * @param response
	 */
	@RequestMapping(value = "/apk/{cateogry:.*}", method = RequestMethod.GET)
	public void apkDownload(@CookieValue(value = "userinfo", defaultValue = "") String userCookie,
			@PathVariable("cateogry") String cateogry,
            HttpServletRequest request,
            HttpServletResponse response){
		downloadService.apkDownload(userCookie, cateogry, request,response);
	}

}
